﻿using SQLite;

namespace LearnMAUI2.Models;

//也copy代码，注意要重新NuGet安装下SQLite
//映射到数据库works表
[Table("poetry")]
public class Poetry
{
    //和id字段建立关系
    [Column("id")]
    public int Id { get; set; }
    [Column("name")]
    public string Name { get; set; } = string.Empty;
    [Column("author")]
    public string Author { get; set; } = string.Empty;
    [Column("dynasty")]
    public string Dynasty { get; set; } = string.Empty;
    [Column("content")]
    public string Content { get; set; } = string.Empty;

    //预览首句诗，也称为虚拟字段，为了避免被ORM处理为字段，需要标记属性为IGNORE
    private string _snippet;
    [Ignore]
    public string Snippet => _snippet ??= Content.Split('。')[0];

}
